<?php
// include function files for this application
require_once('/home/domains/uny-con.com/public_html/uny-con_fns.php');
if (!session_id()) { session_start(); }

//get some variables
   $event_type = $_GET['event_type'];
   if (isset($_GET['sortkey'])) $sortkey = $_GET['sortkey'];
	 else $sortkey = 'event.event_type, event.game_system' ;
   if (isset($_GET['sortdir'])) $sortdir = $_GET['sortdir'];
	 else $sortdir = 'ASC' ;
   if (isset($_GET['searchtype'])) $searchtype = $_GET['searchtype'];
	 else $searchtype = 'all' ;
   if (isset($_GET['searchterm'])) $searchterm = $_GET['searchterm'];
$add_co_gm = $_POST['add_co_gm'];
if (isset($_SESSION['current_attendee_id'])) $attendee_id = $_SESSION['current_attendee_id'];
if (!isset($_SESSION['attendee_id'])) $attendee_id = $_SESSION['current_attendee_id'];

do_html_header('Co-GM Results', gobig, $uny);
if (!check_valid_user()) {
	echo 'You are not logged in, please login with the registration tab above';
	print_brs(6);
	do_html_footer(no_news);
	exit;
	}

if (empty($_POST)) {
	print_event_table(get_event_list($searchtype, $searchkey, $searchterm, $sortkey, $sortdir), cogm, $attendee_id);
	do_html_footer(no_news);
	exit;
	}
	else {
		if (count($add_co_gm) > 0) {
			foreach($add_co_gm as $cogmstring) {
				list($co_gm_attendee_id,$timeslot,$event_id) = explode(".", $cogmstring);
				add_co_gm($co_gm_attendee_id, $event_id, $timeslot);
				}
			}
		echo 'You have been added as a Co-GM to the events you selected, pending approval of the event owner.';
		print_brs(6);
		do_html_footer(no_news);
		}